<?php

// 意见反馈

namespace app\shop\controller;

use think\Request;
use think\Controller;
use app\shop\model\Feedback as FeedbackModel;
use app\shop\model\Information as InformationModel;
use app\shop\model\FeedbackType as FeedbackTypeModel;

class Feedback extends Controller
{
    /**
     * 意见反馈
     * @param Request $request
     * @param FeedbackModel $feedback
     * @param FeedbackTypeModel $feedbackType
     * @return array|mixed
     */
    public function index(Request $request, FeedbackModel $feedback, FeedbackTypeModel $feedbackType)
    {
        if ($request->isPost()) {

            // // 获取参数
            // $data = $request->param();
            //
            // // 新增意见反馈
            // $operation = $feedback->allowField(true)->save($data);

            // if ($operation) {
            //     return ['code' => 200];
            // }

            return ['code' => 200];


        }

        $data = (new InformationModel())->where('parenTid', 41)->select();

        // // 意见反馈类型
        // $feedbackTypes = $feedbackType->where(['status' => 1])->field('id,title')->select()->toArray();


        return $this->fetch('', [
            'mate_head' => '意见反馈',
            'data'      => $data
        ]);
    }


    /**
     * 意见反馈详情
     * @return mixed
     */
    public function detail()
    {
        $fid = Request::instance()->param('id');

        $item = (new InformationModel())->where('id', $fid)->find();


        return $this->fetch('', [
            'mate_head' => "意见反馈",
            'item'      => $item,
        ]);
    }
}